﻿CREATE TABLE [dbo].[Person]
(
    [PersonId] [uniqueidentifier] DEFAULT newid() NOT NULL,
    [LastName] [nvarchar](50) NOT NULL,
    [FirstName] [nvarchar](50) NOT NULL,
    [MiddleName] [nvarchar](50) NULL,
    [Photo] [varbinary](max) NULL,
	[Email] [nvarchar](50) NULL,
	[UserType] [uniqueidentifier] NULL, -- FK to Person
	[PasswordHash] [nvarchar](256) NOT NULL,
	[PasswordSalt] [nvarchar](256) NOT NULL,
	[Login] [nchar](40) NOT NULL,
	[Comment] [nvarchar](max) NULL,
    [CreatedBy] [uniqueidentifier] NULL, -- FK to Person
    [IsDeleted] [bit] DEFAULT 0 NOT NULL,
	[CreatedOn] [datetime] DEFAULT getdate() NOT NULL,
    [LastChanged] [datetime] DEFAULT getdate() NOT NULL,
	[LastChangedBy] [uniqueidentifier] NULL, -- FK to Person
	[TimeStamp] [timestamp] NOT NULL

CONSTRAINT PK_Person PRIMARY KEY CLUSTERED 
(
	[PersonId] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO